package com.example.demo.mvc;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * 统一的错误页面
 * @author lenovn
 *
 */
@ControllerAdvice
public class ExceptionSolver {

	public static final String errorhtml= "error";
	
	@ExceptionHandler(Exception.class)
	public ModelAndView defaultSolver(Exception e)throws Exception{
		ModelAndView modelAndView= new ModelAndView();
		modelAndView.addObject("etn",e);
		modelAndView.setViewName(errorhtml);
		return modelAndView;
	}
}
